<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$member=$this->model('member')->checkmember('',true);
if($_RQ['op']=='main'){
	$data=model('jy_yuyue/model')->get_days();
	$return['data']=$data;
	$return['post']=array('timeid'=>'no');
	$return['post']['dayid']=0;
	exi($return);
}
if($_RQ['op']=='worker_list'){
	$dayid=intval($_RQ['day']);
	if(!isset($_RQ['day'])){
		exi('请重新选择日期','error');
	}
	$post=get_postdata();
	$worker_list=pdo_getall('jy_yuyue_worker',array('uniacid'=>$_SESSION['uniacid'],'islock'=>'0','status'=>'1'));
	$return['worker_list']=$worker_list;
	$return['success']=1;
	$return['weekid']=$weekid;
	$return['dayid']=$dayid;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$data=model('jy_yuyue/model')->get_days();
		$selfcount=pdo_count('jy_yuyue_order',array('serve_id'=>0,'uniacid'=>$_SESSION['uniacid'],'day'=>$data[$postdata['dayid']]['ymd']),'id');
		$daysnum=$data[$postdata['dayid']]['ymd'];
		$daysnum=str_replace(':','',$daysnum);
		$selfnumber=$daysnum.sprintf("%03d", $selfcount+1);
		$insert=array(
			'uniacid'=>$_SESSION['uniacid'],
			'user_id'=>$_SESSION['uid'],
			'worker_id'=>$postdata['worker_id'],
			'serve_id'=>0,
			'merchid'=>0,
			'package'=>ijson_encode($package[$postdata['packageid']]),
			'money'=>0,
			'total'=>1,
			'timeid'=>0,
			'day'=>$data[$postdata['dayid']]['ymd'],
			'address'=>$member['address'],
			'username'=>$member['realname'],
			'mobile'=>$member['mobile'],
			'ordersn'=>get_ordersn('jy_yuyue_order','ordersn'),
			'remark'=>'预约下点指导！',
			'selfnumber'=>$selfnumber,
			'status'=>1,
			'createtime'=>TIMESTAMP,
		);
		pdo_insert('jy_yuyue_order',$insert);
		exi('预约成功！','','jy_area_dai/order/');
}
?>